package com.cloud.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cloud.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Size;

/**
 * 岗位表 sys_post
 *
 * @author yzj
 */
@Data
@Schema(name = "岗位对象", description = "系统管理")
@TableName("sys_post")
public class SysPost extends BaseEntity {

    @Schema(description = "岗位序号")
    @Excel(name = "岗位序号", orderNum = "1", width = 15)
    @TableId(value = "post_id", type = IdType.AUTO)
    private Long postId;

    @Schema(description = "岗位编码")
    @Excel(name = "岗位编码", orderNum = "2", width = 15)
    private String postCode;

    @Schema(description = "岗位名称")
    @Excel(name = "岗位名称", orderNum = "3", width = 15)
    private String postName;

    @Schema(description = "岗位排序")
    @Excel(name = "岗位排序", orderNum = "4", width = 10)
    private String postSort;

    @Schema(description = "状态(0=正常,1=停用)")
    @Excel(name = "状态", orderNum = "5", width = 10, replace = {"正常_0", "停用_1"})
    private Integer status;

    @TableField(exist = false)
    @Schema(description = "用户是否存在此岗位标识 默认不存在")
    private boolean flag = false;

    @Schema(description = "备注")
    @Excel(name = "备注", orderNum = "6", width = 20)
    private String remark;

    @NotBlank(message = "岗位编码不能为空")
    @Size(min = 0, max = 64, message = "岗位编码长度不能超过64个字符")
    public String getPostCode() {
        return postCode;
    }

    @NotBlank(message = "岗位名称不能为空")
    @Size(min = 0, max = 50, message = "岗位名称长度不能超过50个字符")
    public String getPostName() {
        return postName;
    }

    @NotBlank(message = "显示顺序不能为空")
    public String getPostSort() {
        return postSort;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("postId", getPostId())
                .append("postCode", getPostCode())
                .append("postName", getPostName())
                .append("postSort", getPostSort())
                .append("status", getStatus())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}
